package com.xyy.saas.payment.common.enums;

import com.alibaba.fastjson.JSONObject;
import com.xyy.saas.payment.cores.enums.AccountTypeEnum;
import com.xyy.saas.payment.util.JSONUtils;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;

@Getter
public enum YopProductInfoEnum {
    D1("D1_自动结算", "D1", "SINGLE_FIXED", "0", "PLATFORM_MERCHANT", "PREPAID_REAL"),
    ENTERPRISE_RECHARGE_STANDARD_B2B("企业账户充值_网银B2B_标准版", "ENTERPRISE_RECHARGE_STANDARD_B2B_SAMENAME", "SINGLE_FIXED", "8", "PLATFORM_MERCHANT", "PREPAID_REAL"),
    ENTERPRISE_RECHARGE_STANDARD_BANK_TRASFER("企业账户充值标准版_银行汇款", "ENTERPRISE_RECHARGE_STANDARD_BANK_TRASFER", "SINGLE_FIXED", "8", "PLATFORM_MERCHANT", "PREPAID_REAL"),
    ENTERPRISE_TRANSFER_B2B("企业账户转账_公对公", "ENTERPRISE_TRANSFER_B2B", "SINGLE_FIXED", "0", "PLATFORM_MERCHANT", "PREPAID_REAL"),
    ENTERPRISE_WITHDRAW_STANDARD_REALTIME("企业账户提现标准版_实时到账", "ENTERPRISE_WITHDRAW_STANDARD_REALTIME", "SINGLE_FIXED", "0.5", "PLATFORM_MERCHANT", "PREPAID_REAL"),
    ;

    /**
     * 获取产品列表
     */
    public static String getProductList(String accountType) {
        List<JSONObject> productList = new ArrayList<>();

        for(YopProductInfoEnum item : values()) {
            // 个人账户不开转账产品
            if(AccountTypeEnum.CUSTOMER.getType().equals(accountType) && item == ENTERPRISE_TRANSFER_B2B) {
                continue;
            }

            JSONObject product = new JSONObject();
            product.put("productCode", item.getProductCode());
            product.put("rateType", item.getRateType());
            product.put("fixedRate", item.getFixedRate());
            product.put("undertaker", item.getUndertaker());
            product.put("paymentMethod", item.getPaymentMethod());
            productList.add(product);
        }

        return JSONUtils.toJSON(productList);
    }

    YopProductInfoEnum(String productName, String productCode, String rateType, String fixedRate, String undertaker, String paymentMethod) {
        this.productName = productName;
        this.productCode = productCode;
        this.rateType = rateType;
        this.fixedRate = fixedRate;
        this.undertaker = undertaker;
        this.paymentMethod = paymentMethod;
    }

    // 产品名称
    private String productName;
    // 产品码
    private String productCode;
    // 计费策略
    private String rateType;
    // 单笔百分比(暂时未用到)
    private String percentRate;
    // 单笔固定值
    private String fixedRate;
    // 手续费承担方
    private String undertaker;
    // 手续费收取方式
    private String paymentMethod;
}
